﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace MOJsdk
{
    public interface IPanel : IEquatable<IPanel>
    {
        UserControl Control { get; }
        string PanelIdentifier { get; }
        string PanelType { get; }

        void LoadMovies();

        void Focus();
        void SelectNext();
        void SelectPrev();
        void SelectIndex(int Index);

        void SelectMovie(string MovieCode);
        void SelectMovies(List<string> MovieCodes);

        void SelectFile(int FileId);
        void SelectFiles(List<int> FileIds);

        int CollectionSize { get; }
        bool IsMultiSelect { get; }

        string SelectedMovie { get; }
        int SelectedFile { get; }

        List<string> SelectedMovies { get; }
        List<int> SelectedFiles { get; }

        void ApplyMovieFilter();
        void ApplyMovieOrder();

        void ApplyFileFilter();
        void ApplyFileOrder();

        event SelectedMovieChangedHandler OnSelectedMovieChanged;
        event SelectedFileChangedHandler OnSelectedFileChanged;
        event CallEventHandler OnLoadComplete;
    }
    public class EmptyPanel : IPanel
    {
        public EmptyPanel()
        {
            OnLoadComplete += delegate { };
            OnSelectedFileChanged += delegate { };
            OnSelectedMovieChanged += delegate { };
        }

        public UserControl Control { get { return null; } }
        public string PanelIdentifier { get { return "Empty"; } }
        public string PanelType { get { return "Empty"; } }

        public void LoadMovies()
        {

        }

        public void Focus() { }
        public void SelectNext() { }
        public void SelectPrev() { }
        public void SelectIndex(int Index) { }

        public void SelectMovie(string MovieCode) { }
        public void SelectMovies(List<string> MovieCodes) { }

        public void SelectFile(int FileId) { }
        public void SelectFiles(List<int> FileIds) { }

        public int CollectionSize { get { return 0; } }
        public bool IsMultiSelect { get { return false; } }

        public string SelectedMovie { get { return "NULL"; } }
        public int SelectedFile { get { return -1; } }

        public List<string> SelectedMovies { get { return new List<string>(); } }
        public List<int> SelectedFiles { get { return new List<int>(); } }

        public void ApplyMovieFilter() { }
        public void ApplyMovieOrder() { }

        public void ApplyFileFilter() { }
        public void ApplyFileOrder() { }

        public event SelectedMovieChangedHandler OnSelectedMovieChanged;
        public event SelectedFileChangedHandler OnSelectedFileChanged;
        public event CallEventHandler OnLoadComplete;

        public bool Equals(IPanel Panel)
        {
            return this.PanelIdentifier == Panel.PanelIdentifier;
        }
    }
    public class MojIPanelStandardTypes
    {
        public static string BrowseMovies
        { get { return "BrowseMovies"; } }
        public static string ManageMovies
        { get { return "ManageMovies"; } }
        public static string BrowseFiles
        { get { return "BrowseFiles"; } }
        public static string ManageFiles
        { get { return "ManageFiles"; } }
    }
}
